#ifndef PLAYER_H
#define PLAYER_H
//this class is used to provide all player informations.
//any widget that needs player information should access from here.
#include <QObject>
#include <QPoint>
#include <QPainter>
#include <QPixmap>
#include "gs.h"
#include "gameboarditem.h"
#include "gameboardorganizer.h"

using namespace gs;

namespace gs
{
class Player : public QObject
{
    Q_OBJECT

public:
    explicit Player(QObject *parent = 0);
    //get methods
    int            getResistR      () { return _resistR; }
    int            getResistBlue   () { return _resistBlue; }
    int            getResistY      () { return _resistY; }
    int            getResistG      () { return _resistG; }
    int            getResistBlack  () { return _resistBlack; }
    int            getQi           () { return _qiNum;}
    int            getBudd         () { return _buddhaNum;}
    QPoint*        getPlayerPos    () { return _pos;}
    QPoint         getMoveDirection() { return _moveDir;}
    QPoint*        getMoveDistance (QPoint* p);

    bool           isskillUsed     () { return _skilled; }
    bool           isDead          () { return _isDead; }
    bool           hasYinyang      () { return _hasYinyang; }
    bool           isSkillSealed   () { return _skillSealed; }
    bool           isActionUsed    () { return _actionUsed; }
    QPixmap        getPlayerHead   () { return _pHead; }
    PlayerSkillObject* getPlayerSkill () { return _pskill; }
    PlayerIcon*    getPlayerIcon   () { return _pIcon; }
    GhostBoard*    getGhostBoard(){return _board;}

    //set methods
    void           setResistR      (int r) {_resistR = r;}
    void           setResistBlue   (int r) {_resistBlue = r;}
    void           setResistY      (int r) {_resistY = r;}
    void           setResistG      (int r) {_resistG = r;}
    void           setResistBlack  (int r) {_resistBlack = r;}
    void           setQi           (int q) {_qiNum = q;}
    void           setBudda        (int b) {_buddhaNum = b;}
    void           setPlayerPos    (QPoint* p);
    void           setSkilled      (bool s) {_skilled = s;}
    void           setDead         (bool d) {_isDead = d;}
    void           setYinyang      (bool y) {_hasYinyang = y;}
    void           setSkillSealed  (bool s) {_skillSealed = s;}
    void           setActionUsed   (bool a) {_actionUsed = a;}
    void           setPlayerHead   (QPixmap p) {_pHead = p;}
    void           setPlayerSkill  (PlayerSkillObject* s) { _pskill = s; }
    void           setPlayerIcon   (PlayerIcon* i) {_pIcon = i;}

    //change methos
    void YinyangChange(bool isIncease);
    void qiChange(bool isIncease);
    void buddaChange(bool isIncese);
    void checkDead();
    void resistChangeR(bool isIncease);
    void resistChangeBlue(bool isIncease);
    void resistChangeY(bool isIncease);
    void resistChangeG(bool isIncease);
    void resistChangeBlack(bool isIncease);

    void setDefaultItem();
    Player* receiveBoard(GhostBoard*);
    void resetAllResists();
private:
    int           _resistR;
    int           _resistBlue;
    int           _resistY;
    int           _resistG;
    int           _resistBlack;
    int           _qiNum;
    int           _buddhaNum;
    QPoint*       _pos;
    QPoint        _moveDir;
    bool          _isDead;
    bool          _skilled;
    bool          _actionUsed;
    bool          _hasYinyang;
    bool          _skillSealed;
    QPixmap       _pHead;
    PlayerSkillObject* _pskill;
    PlayerIcon*   _pIcon;


protected:
    //the board player belongs to
    GhostBoard* _board;
signals:
    void taoChanged();
    void posChanged();
    void actionChanged();
public slots:

};

class PlayerIcon : public GameBoardItem
{
    Q_OBJECT
public:
    PlayerIcon(GameBoardOrganizer* parent = 0, QPixmap pm=0, Player* p=0);
    QRectF boundingRect() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);

protected:
    int _iconW;
    int _iconH;
    QPixmap _iconP;
    Player* _pl;
protected slots:
    void updateIconPos();

};


}
#endif // PLAYER_H
